/**
 * Created by wangjh on 2018/12/3.
 */

function Animal(name) {
    // 属性
    this.name = name || 'Animal';
    // 实例方法
    this.sleep = function () {
        console.log(this.name + '正在睡觉！');
    }
}
// 原型方法
Animal.prototype.eat = function (food) {
    console.log(this.name + '正在吃：' + food);

    return 0;
}
function Cat() {
}
Cat.prototype = new Animal();
Cat.prototype.name = 'cat';

// Test Code
var cat = new Cat();
console.log(cat.name);//cat
var c = cat.eat('fish');//cat正在吃fish
var d = cat.sleep();//cat正在睡觉！
console.log(c);//cat.eat() = console.log('')
console.log(d);
console.log(cat instanceof Animal);
console.log(cat instanceof Cat);
